package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.service.project.backandforth.IBackAndForthService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.BackAndForth;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 往来管理Controller
 * 
 * @author yuxiang.chen
 * @date 2023-08-03
 */
@RestController
@RequestMapping("/system/forth")
public class BackAndForthController extends BaseController
{
    @Autowired
    private IBackAndForthService backAndForthService;

    /**
     * 查询往来管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:forth:list')")
    @GetMapping("/list")
    public TableDataInfo list(BackAndForth backAndForth)
    {
        startPage();
        List<BackAndForth> list = backAndForthService.selectBackAndForthList(backAndForth);
        return getDataTable(list);
    }

    /**
     * 导出往来管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:forth:export')")
    @Log(title = "往来管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BackAndForth backAndForth)
    {
        List<BackAndForth> list = backAndForthService.selectBackAndForthList(backAndForth);
        ExcelUtil<BackAndForth> util = new ExcelUtil<BackAndForth>(BackAndForth.class);
        util.exportExcel(response, list, "往来管理数据");
    }

    /**
     * 获取往来管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:forth:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(backAndForthService.selectBackAndForthById(id));
    }

    /**
     * 新增往来管理
     */
    //@PreAuthorize("@ss.hasPermi('system:forth:add')")
    @Log(title = "往来管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BackAndForth backAndForth)
    {
        return toAjax(backAndForthService.insertBackAndForth(backAndForth));
    }

    /**
     * 修改往来管理
     */
    //@PreAuthorize("@ss.hasPermi('system:forth:edit')")
    @Log(title = "往来管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BackAndForth backAndForth)
    {
        return toAjax(backAndForthService.updateBackAndForth(backAndForth));
    }

    /**
     * 删除往来管理
     */
    //@PreAuthorize("@ss.hasPermi('system:forth:remove')")
    @Log(title = "往来管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(backAndForthService.deleteBackAndForthByIds(ids));
    }
}
